﻿using Basic.FlowApplication.Interface;
using Basic.FlowRemoteModel;
using WeDonekRpc.Client.Interface;

namespace Basic.FlowApplication.AuditLocalEvent.AuditEvent
{
    internal class RestoreSignFile : IEventHandler<FlowAuditEvent>
    {
        private readonly IAuditSignLogService _Service;

        public RestoreSignFile ( IAuditSignLogService service )
        {
            this._Service = service;
        }

        public void HandleEvent ( FlowAuditEvent data, string eventName )
        {
            if ( data.Item.AuditState == FlowAuditItemStatus.审核通过 && data.Item.MarkState == FlowItemMarkState.退回 )
            {
                this._Service.Restore(data.Log.Id, data.Item.OptItemId.Value);
            }
        }
    }
}
